package com.tyk.bookstore.back.storage.util;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tyk.bookstore.back.common.core.model.type.BinVo;
import com.tyk.bookstore.back.storage.manager.excel.model.StockExcelVo;
import com.tyk.bookstore.back.storage.manager.excel.model.WarehouseExcelVo;
import com.tyk.bookstore.back.storage.model.dto.WarehouseDto;
import com.tyk.bookstore.back.storage.model.entity.StockDo;
import com.tyk.bookstore.back.storage.model.entity.WarehouseDo;
import com.tyk.bookstore.back.storage.model.query.StockAddQuery;
import com.tyk.bookstore.back.storage.model.query.StockUpdateQuery;
import com.tyk.bookstore.back.storage.model.query.WarehouseAddQuery;
import com.tyk.bookstore.back.storage.model.query.WarehouseUpdateQuery;
import com.tyk.bookstore.back.storage.model.vo.StockPageVo;
import com.tyk.bookstore.back.storage.model.vo.StockVo;
import com.tyk.bookstore.back.storage.model.vo.WarehousePageVo;
import com.tyk.bookstore.back.storage.model.vo.WarehouseVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

import java.util.List;

@Mapper(componentModel = "spring")
public interface MapStructStorage {
    @Mappings({
            @Mapping(target = "areaName", ignore = true),
            @Mapping(target = "userName", ignore = true)
    })
    WarehouseVo toWarehouseVo(WarehouseDo warehouse);

    WarehousePageVo toWarehousePageVo(Page<WarehouseDo> page);

    @Mappings({

            @Mapping(target = "userName", ignore = true)

    })
    WarehousePageVo.Warehouse toWarehousePageVo$Warehouse(WarehouseDo warehouseDo);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true)
    })
    WarehouseDo toWarehouseDo(WarehouseAddQuery query);

    @Mappings({
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true)
    })
    WarehouseDo toWarehouseDo(WarehouseUpdateQuery query);

    @Mappings({
            @Mapping(target = "warehouseName", ignore = true),
            @Mapping(target = "bookName", ignore = true)
    })
    StockVo toStockVo(StockDo stock);

    StockPageVo toStockPageVo(Page<StockDo> page);

    @Mappings({
            @Mapping(target = "warehouseName", ignore = true),
            @Mapping(target = "bookName", ignore = true),
            @Mapping(target = "bookIsbn", ignore = true),
            @Mapping(target = "bookNo", ignore = true)
    })
    StockPageVo.Stock toStockPageVo$Stock(StockDo stockDo);

    @Mappings({
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true)
    })
    StockDo toStockDo(StockAddQuery query);

    @Mappings({
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true)
    })
    StockDo toStockDo(StockUpdateQuery query);

    WarehouseDto toWarehouseDto(WarehouseDo warehouse);

    List<BinVo> toSuggestionVoList(List<WarehouseDo> doList);

    List<WarehouseExcelVo> toWarehouseExcelVo(List<WarehouseDo> doList);

    List<WarehouseDo> toWarehouseDoList(List<WarehouseExcelVo> warehouseList);

    @Mappings({
            @Mapping(target = "id", ignore = true),
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true),
    })
    WarehouseDo toWarehouseDo(WarehouseExcelVo vo);

    List<StockExcelVo> toStockExcelVo(List<StockDo> doList);

    List<StockDo> toStockDoList(List<StockExcelVo> stockList);

    @Mappings({
            @Mapping(target = "createTime", ignore = true),
            @Mapping(target = "updateTime", ignore = true),
    })
    StockDo toStockDo(StockExcelVo stock);
}
